import Vue from 'vue'
import VueRouter from 'vue-router'
// 1.安装插件
Vue.use(VueRouter)
//  2.创建路由对象
//  懒加载方式 推荐方式
const home = () => import('@/pages/home/Home')
const cart = () => import('@/pages/cart/Cart')
const profile = () => import('@/pages/profile/Profile')
const category = () => import('@/pages/category/Category')

const routes = [
  { path: '/', redirect: home }, // 设置默认路径
  { path: '/home', component: home },
  { path: '/cart', component: cart },
  { path: '/profile', component: profile },
  { path: '/category', component: category }
]
const router = new VueRouter({
  routes,
  mode: 'history'
})

// 3.将router 对象传入到vue实例
export default router
